﻿using System;

namespace Geometria
{
    /// <summary>
    /// 
    /// </summary>
    public struct Punto : IEquatable<Punto>
    {
        #region Fields

        private float x;
        private float y;
        private float z;

        #endregion Fields

        #region Constructors

        /// <summary>
        /// 
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="z"></param>
        public Punto(float x, float y, float z)
        {
            this.x = x;
            this.y = y;
            this.z = z;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="z"></param>
        public Punto(double x, double y, double z)
        {
            this.x = (float)x;
            this.y = (float)y;
            this.z = (float)z;
        }

        #endregion Constructors

        #region Properties

        /// <summary>
        /// 
        /// </summary>
        public static Punto Cero
        {
            get { return new Punto(0, 0, 0); }
        }

        /// <summary>
        /// 
        /// </summary>
        public float X
        {
            get { return x; }
            set { x = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        public float Y
        {
            get { return y; }
            set { y = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        public float Z
        {
            get { return z; }
            set { z = value; }
        }

        #endregion Properties

        #region Methods

        public static Punto operator +(Punto p, Vector v)
        {
            return v + p;
        }

        public static Vector operator -(Punto p1, Punto p2)
        {
            return new Vector(p1.X - p2.X, p1.Y - p2.Y, p1.Z - p2.Z);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="other"></param>
        /// <returns></returns>
        public double Distancia(Punto other)
        {
            return (this - other).Longitud;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="other"></param>
        /// <returns></returns>
        public bool Equals(Punto other)
        {
            return this.X == other.X
                && this.Y == other.Y
                && this.Z == other.Z;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            return "(" + this.X.ToString()
                 + ", " + this.Y.ToString()
                 + ", " + this.Z.ToString()
                 + ")";
        }

        #endregion Methods
    }
}